/*
 * To change this template, choose Tools | Templates and open the template in
 * the editor.
 */

/*
 * ManagerAdmin.java
 *
 * Created on Nov 13, 2011, 12:52:23 AM
 */
package swing;

import config.MyConnection;
import java.awt.Color;
import java.awt.Font;
import java.awt.Image;
import java.awt.Toolkit;
import java.beans.Statement;
import java.io.File;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author TieuLink1610
 */
public class ManagerAdmin extends javax.swing.JFrame {

    Image iconFrame = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/images/question_mark_icon_blueglow.png"));
    ImageIcon IconEdit = new ImageIcon("/images/edit.png");
    ImageIcon IconDelete = new ImageIcon("/images/delete.png");
    public static int x;
    public static int y;
    boolean state = false;
    boolean check = false;
    ImageIcon showerror = new ImageIcon("/images/dialog_warning.png");
    Image image = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/images/password2.png"));
    Icon icon = new ImageIcon(image);
    DefaultTableModel dtmQuestion = new DefaultTableModel();
    DefaultTableModel dtmPlayer = new DefaultTableModel();
    DefaultTableModel dtmSearch = new DefaultTableModel();
    Connection connect = null;
    ResultSet data, dataQuestion, dataPlayer, dataOneRow, dataOneRowSearch;
    ResultSetMetaData metaQuestion, metaPlayer, metaSearch;
    Statement st;
    String A, B, C, D;

    /** Creates new form ManagerAdmin */
    public ManagerAdmin() {
        this.setIconImage(iconFrame);
        initComponents();
        this.setAlwaysOnTop(true);
        loadQuestion();
        loadPlayer();
        viewMaxMoney();
        viewPlayerMax();
        viewTotalPlayer();
        viewTotalQuestion();
        this.setLocationRelativeTo(null);
        tableQuestion.getTableHeader().setForeground(Color.red);
        tableQuestion.getTableHeader().setFont(new Font("Tahoma", 1, 12));
        tablePlayer.getTableHeader().setFont(new Font("Tahoma", 1, 12));
        tablePlayer.getTableHeader().setForeground(Color.red);
        tableSearch.getTableHeader().setFont(new Font("Tahoma", 1, 12));
        tableSearch.getTableHeader().setForeground(Color.red);

        MyConnection.getConnect();
    }

    private void viewTotalPlayer() {
        try {
            //get total Player
            String sqlTotalUser = "select count(*)[countIDUser] from Player";
            connect = MyConnection.getConn();
            ResultSet rsTotalPlayer = MyConnection.resultSet(sqlTotalUser);
            rsTotalPlayer.next();
            countUser.setText(rsTotalPlayer.getString(1));
        } catch (Exception e) {
        }
    }

    private void viewTotalQuestion() {
        try {
            // get total Question
            String sqlTotalQuestion = "select count(*)[countIDQuestion] from Question";
            connect = MyConnection.getConn();
            ResultSet rsTotalQuestion = MyConnection.resultSet(sqlTotalQuestion);
            rsTotalQuestion.next();
            countQuestion.setText(rsTotalQuestion.getString(1));
        } catch (Exception e) {
        }
    }

    private void viewMaxMoney() {
        try {
            // get Max Money
            String sqlMaxMoney = "select max(Money) from Player";
            ResultSet rsMaxMoney = MyConnection.resultSet(sqlMaxMoney);
            rsMaxMoney.next();
            maxMoney.setText(rsMaxMoney.getString(1));
        } catch (Exception e) {
        }
    }

    private void viewPlayerMax() {
        try {
            // get Player have Money max
            String sqlPlayerMaxMoney = "select Player.* from Player where Player.Money = (Select Max(Player.Money) from Player)";
            ResultSet rsPlayerMax = MyConnection.resultSet(sqlPlayerMaxMoney);
            rsPlayerMax.next();
            lbName.setText(rsPlayerMax.getString("UserName"));
            lbEmail.setText(rsPlayerMax.getString("Email"));
            lbDate.setText(""+rsPlayerMax.getDate("DateOfBirth"));
            lbAddress.setText(rsPlayerMax.getString("Address"));
        } catch (Exception e) {
        }
    }

    public int chooseRow(JTable tableName) throws SQLException {
        // TODO add your handling code here:
        int choose = tableName.getSelectedRow();
        int chooseRow = choose + 1;
        ResultSet load = loadData("Question");
        load.absolute(chooseRow);
        int id = load.getInt("Id");
        return id;
    }

    public void loadQuestionAgain() {
        dtmQuestion = new DefaultTableModel(0, 0);
        loadQuestion();
    }

    public void reset() {
        txtContent.setText("");
        txtA.setText("");
        txtB.setText("");
        txtC.setText("");
        txtD.setText("");
        buttonGroup1.clearSelection();
    }

    private void loadQuestion() {
        try {
            dataQuestion = loadData("Question");

            tableQuestion.setModel(dtmQuestion);

            metaQuestion = dataQuestion.getMetaData();
            int totalColumn = metaQuestion.getColumnCount();
            for (int i = 1; i <= totalColumn; i++) {
                dtmQuestion.addColumn(metaQuestion.getColumnLabel(i));
            }

            while (dataQuestion.next()) {
                Vector rowQuestion = new Vector();

                rowQuestion.add(dataQuestion.getInt(1));
                rowQuestion.add(dataQuestion.getString(2));
                rowQuestion.add(dataQuestion.getString(3));
                rowQuestion.add(dataQuestion.getString(4));
                rowQuestion.add(dataQuestion.getString(5));
                rowQuestion.add(dataQuestion.getString(6));
                rowQuestion.add(dataQuestion.getString(7));
                dtmQuestion.addRow(rowQuestion);
            }
        } catch (Exception ex) {
            ex.getStackTrace();
        }

    }

    public ResultSet loadData(String tableName) {
        String sql = "select * from " + tableName + "";
        connect = MyConnection.getConn();
        data = MyConnection.resultSet(sql);
        return data;
    }

    private void loadPlayer() {
        try {
            dataPlayer = loadData("Player");

            tablePlayer.setModel(dtmPlayer);

            metaPlayer = dataPlayer.getMetaData();
            int totalColumn = metaPlayer.getColumnCount();
            for (int i = 1; i <= totalColumn; i++) {
                dtmPlayer.addColumn(metaPlayer.getColumnLabel(i));
            }

            while (dataPlayer.next()) {

                Vector rowPlayer = new Vector();
                rowPlayer.add(dataPlayer.getInt(1));
                rowPlayer.add(dataPlayer.getString(2));
                rowPlayer.add(dataPlayer.getString(3));
                rowPlayer.add(dataPlayer.getObject(4));
                rowPlayer.add(dataPlayer.getString(5));
                rowPlayer.add(dataPlayer.getInt(6));
                dtmPlayer.addRow(rowPlayer);
            }
        } catch (Exception ex) {
            ex.getStackTrace();
        }

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        pnTitle = new javax.swing.JPanel();
        jLabel14 = new javax.swing.JLabel();
        tpManager = new javax.swing.JTabbedPane();
        pnStatistics = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        countUser = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        maxMoney = new javax.swing.JLabel();
        maxMoney1 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        lbEmail = new javax.swing.JLabel();
        lbDate = new javax.swing.JLabel();
        lbAddress = new javax.swing.JLabel();
        countQuestion = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        lbManage = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        lbName = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        pnQuestion = new javax.swing.JPanel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        pnTabQuestion = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        tableQuestion = new javax.swing.JTable();
        pnInfomation = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        txtContent = new javax.swing.JTextArea();
        jLabel8 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        rdA = new javax.swing.JRadioButton();
        rdB = new javax.swing.JRadioButton();
        rdC = new javax.swing.JRadioButton();
        rdD = new javax.swing.JRadioButton();
        btnReset = new javax.swing.JButton();
        btnDelete = new javax.swing.JButton();
        btnAdd = new javax.swing.JButton();
        txtD = new javax.swing.JTextField();
        btnUpdate = new javax.swing.JButton();
        txtC = new javax.swing.JTextField();
        txtB = new javax.swing.JTextField();
        txtA = new javax.swing.JTextField();
        pnSearchQuestion = new javax.swing.JPanel();
        jPanel6 = new javax.swing.JPanel();
        btnSearch1 = new javax.swing.JButton();
        txtSearh = new javax.swing.JTextField();
        jLabel25 = new javax.swing.JLabel();
        jPanel7 = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        tableSearch = new javax.swing.JTable();
        pnUser = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tablePlayer = new javax.swing.JTable();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        mnPass = new javax.swing.JMenuItem();
        mnLog = new javax.swing.JMenuItem();
        mnExit = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(jTable1);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Manager Admin Cpanel");
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosed(java.awt.event.WindowEvent evt) {
                formWindowClosed(evt);
            }
        });

        pnTitle.setBackground(new java.awt.Color(0, 153, 255));
        pnTitle.setPreferredSize(new java.awt.Dimension(1024, 690));

        jLabel14.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel14.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/top.png"))); // NOI18N
        jLabel14.setMaximumSize(new java.awt.Dimension(800, 100));
        jLabel14.setMinimumSize(new java.awt.Dimension(800, 100));
        jLabel14.setPreferredSize(new java.awt.Dimension(800, 100));

        tpManager.setBackground(new java.awt.Color(255, 255, 255));
        tpManager.setTabPlacement(javax.swing.JTabbedPane.LEFT);
        tpManager.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        tpManager.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        tpManager.setPreferredSize(new java.awt.Dimension(1024, 700));
        tpManager.setVerifyInputWhenFocusTarget(false);
        tpManager.addAncestorListener(new javax.swing.event.AncestorListener() {
            public void ancestorMoved(javax.swing.event.AncestorEvent evt) {
            }
            public void ancestorAdded(javax.swing.event.AncestorEvent evt) {
                tpManagerAncestorAdded(evt);
            }
            public void ancestorRemoved(javax.swing.event.AncestorEvent evt) {
            }
        });

        pnStatistics.setBackground(new java.awt.Color(255, 255, 255));
        pnStatistics.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Statistics", 2, 1, new java.awt.Font("Tahoma", 1, 18))); // NOI18N

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel1.setForeground(javax.swing.UIManager.getDefaults().getColor("CheckBoxMenuItem.selectionBackground"));
        jLabel1.setText("Admin Cpanel KBC Quiz Show");

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel2.setText("Total :");

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel6.setText("Question");

        countUser.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        countUser.setForeground(new java.awt.Color(0, 102, 102));

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel3.setText("Max Money : ");

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel4.setText("Total :");

        maxMoney.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        maxMoney.setForeground(new java.awt.Color(0, 0, 153));

        maxMoney1.setFont(new java.awt.Font("Tahoma", 3, 12)); // NOI18N
        maxMoney1.setText("Player have money max :");

        jLabel13.setText("$");

        lbEmail.setFont(new java.awt.Font("Tahoma", 3, 14)); // NOI18N
        lbEmail.setForeground(new java.awt.Color(0, 102, 102));

        lbDate.setFont(new java.awt.Font("Tahoma", 3, 14)); // NOI18N
        lbDate.setForeground(new java.awt.Color(0, 102, 102));

        lbAddress.setFont(new java.awt.Font("Tahoma", 3, 14)); // NOI18N
        lbAddress.setForeground(new java.awt.Color(0, 102, 102));

        countQuestion.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        countQuestion.setForeground(new java.awt.Color(0, 102, 102));

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel7.setText("User");

        lbManage.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        lbManage.setForeground(new java.awt.Color(0, 102, 102));
        lbManage.setText("Account Managent");
        lbManage.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lbManageMouseClicked(evt);
            }
        });

        jLabel21.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel21.setText("Name :");

        lbName.setFont(new java.awt.Font("Tahoma", 3, 14)); // NOI18N
        lbName.setForeground(new java.awt.Color(0, 102, 102));

        jLabel22.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel22.setText("Date Of Birth :");

        jLabel23.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel23.setText("Email :");

        jLabel24.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel24.setText("Address :");

        javax.swing.GroupLayout pnStatisticsLayout = new javax.swing.GroupLayout(pnStatistics);
        pnStatistics.setLayout(pnStatisticsLayout);
        pnStatisticsLayout.setHorizontalGroup(
            pnStatisticsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnStatisticsLayout.createSequentialGroup()
                .addGap(360, 360, 360)
                .addGroup(pnStatisticsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnStatisticsLayout.createSequentialGroup()
                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 276, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(221, 221, 221))
                    .addGroup(pnStatisticsLayout.createSequentialGroup()
                        .addGroup(pnStatisticsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnStatisticsLayout.createSequentialGroup()
                                .addComponent(jLabel21)
                                .addGap(3, 3, 3)
                                .addComponent(lbName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(pnStatisticsLayout.createSequentialGroup()
                                .addComponent(jLabel23)
                                .addGap(18, 18, 18)
                                .addComponent(lbEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(pnStatisticsLayout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(maxMoney, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(pnStatisticsLayout.createSequentialGroup()
                                .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(countUser, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel7))
                            .addGroup(pnStatisticsLayout.createSequentialGroup()
                                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(countQuestion, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jLabel6)))
                        .addGap(44, 44, 44)
                        .addGroup(pnStatisticsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel24)
                            .addComponent(jLabel22))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pnStatisticsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lbAddress, javax.swing.GroupLayout.PREFERRED_SIZE, 205, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lbDate, javax.swing.GroupLayout.PREFERRED_SIZE, 205, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap(20, Short.MAX_VALUE))
                    .addGroup(pnStatisticsLayout.createSequentialGroup()
                        .addComponent(maxMoney1, javax.swing.GroupLayout.PREFERRED_SIZE, 236, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnStatisticsLayout.createSequentialGroup()
                .addGap(450, 460, Short.MAX_VALUE)
                .addComponent(lbManage, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(363, 363, 363))
        );
        pnStatisticsLayout.setVerticalGroup(
            pnStatisticsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnStatisticsLayout.createSequentialGroup()
                .addGap(77, 77, 77)
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(34, 34, 34)
                .addGroup(pnStatisticsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(countQuestion)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnStatisticsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(countUser)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnStatisticsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(maxMoney)
                    .addComponent(jLabel13))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(maxMoney1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnStatisticsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbDate, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel21)
                    .addComponent(lbName, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel22))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnStatisticsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnStatisticsLayout.createSequentialGroup()
                        .addGroup(pnStatisticsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(lbEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel23))
                        .addGap(150, 150, 150)
                        .addComponent(lbManage))
                    .addGroup(pnStatisticsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(lbAddress, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel24)))
                .addGap(46, 46, 46))
        );

        tpManager.addTab("Statistics", new javax.swing.ImageIcon(getClass().getResource("/images/statc.png")), pnStatistics); // NOI18N

        pnQuestion.setBackground(new java.awt.Color(255, 255, 255));
        pnQuestion.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", 2, 1, new java.awt.Font("Tahoma", 1, 18))); // NOI18N
        pnQuestion.setFocusTraversalPolicyProvider(true);
        pnQuestion.setPreferredSize(new java.awt.Dimension(500, 600));
        pnQuestion.setLayout(new java.awt.BorderLayout());

        jPanel1.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N

        pnTabQuestion.setPreferredSize(new java.awt.Dimension(896, 295));
        pnTabQuestion.setLayout(new java.awt.BorderLayout());

        tableQuestion.setFont(new java.awt.Font("Tahoma", 0, 13)); // NOI18N
        tableQuestion.setModel(dtmQuestion);
        tableQuestion.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tableQuestionMouseClicked(evt);
            }
        });
        jScrollPane3.setViewportView(tableQuestion);

        pnTabQuestion.add(jScrollPane3, java.awt.BorderLayout.CENTER);

        txtContent.setColumns(20);
        txtContent.setRows(5);
        jScrollPane4.setViewportView(txtContent);

        jLabel8.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel8.setText("Content");

        jLabel20.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel20.setForeground(new java.awt.Color(255, 153, 0));
        jLabel20.setText("Information question");

        jLabel10.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel10.setText("Answer A");

        jLabel11.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel11.setText("Answer B");

        jLabel9.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel9.setText("Answer C");

        jLabel12.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel12.setText("Answer D");

        jLabel19.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel19.setText("Correct answer ");

        buttonGroup1.add(rdA);
        rdA.setText("A");

        buttonGroup1.add(rdB);
        rdB.setText("B");

        buttonGroup1.add(rdC);
        rdC.setText("C");

        buttonGroup1.add(rdD);
        rdD.setText("D");

        btnReset.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Refresh.png"))); // NOI18N
        btnReset.setText("Reset");
        btnReset.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnResetActionPerformed(evt);
            }
        });

        btnDelete.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/delete.png"))); // NOI18N
        btnDelete.setText("Delete");
        btnDelete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDeleteActionPerformed(evt);
            }
        });

        btnAdd.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/ok.png"))); // NOI18N
        btnAdd.setText("Add");
        btnAdd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddActionPerformed(evt);
            }
        });

        txtD.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtDActionPerformed(evt);
            }
        });

        btnUpdate.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/edit.png"))); // NOI18N
        btnUpdate.setText("Update");
        btnUpdate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnUpdateActionPerformed(evt);
            }
        });

        txtC.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtCActionPerformed(evt);
            }
        });

        txtB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtBActionPerformed(evt);
            }
        });

        txtA.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtAActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnInfomationLayout = new javax.swing.GroupLayout(pnInfomation);
        pnInfomation.setLayout(pnInfomationLayout);
        pnInfomationLayout.setHorizontalGroup(
            pnInfomationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnInfomationLayout.createSequentialGroup()
                .addGroup(pnInfomationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnInfomationLayout.createSequentialGroup()
                        .addGap(25, 25, 25)
                        .addGroup(pnInfomationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel8)
                            .addGroup(pnInfomationLayout.createSequentialGroup()
                                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 286, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(55, 55, 55)
                                .addGroup(pnInfomationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(pnInfomationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jLabel12)
                                        .addComponent(jLabel11)
                                        .addComponent(jLabel10)
                                        .addComponent(jLabel9))
                                    .addComponent(jLabel19))
                                .addGap(18, 18, 18)
                                .addGroup(pnInfomationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(pnInfomationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(txtC)
                                        .addComponent(txtB)
                                        .addComponent(txtA)
                                        .addComponent(txtD, javax.swing.GroupLayout.PREFERRED_SIZE, 217, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(pnInfomationLayout.createSequentialGroup()
                                        .addComponent(rdA)
                                        .addGap(18, 18, 18)
                                        .addComponent(rdB)
                                        .addGap(18, 18, 18)
                                        .addComponent(rdC)
                                        .addGap(18, 18, 18)
                                        .addComponent(rdD)))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnInfomationLayout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel20)
                        .addGap(222, 222, 222)))
                .addGroup(pnInfomationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(btnUpdate, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnAdd, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnDelete, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnReset, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(52, 52, 52))
        );
        pnInfomationLayout.setVerticalGroup(
            pnInfomationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnInfomationLayout.createSequentialGroup()
                .addGroup(pnInfomationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnInfomationLayout.createSequentialGroup()
                        .addGap(25, 25, 25)
                        .addGroup(pnInfomationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel8)
                            .addComponent(btnAdd, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(pnInfomationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnInfomationLayout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(pnInfomationLayout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addComponent(btnUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(btnDelete, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(btnReset, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(pnInfomationLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel20)
                        .addGap(25, 25, 25)
                        .addGroup(pnInfomationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel10)
                            .addComponent(txtA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(pnInfomationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtB, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel11))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(pnInfomationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtC, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel9))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(pnInfomationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtD, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel12))
                        .addGap(18, 18, 18)
                        .addGroup(pnInfomationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(rdB)
                            .addComponent(rdC)
                            .addComponent(rdA)
                            .addComponent(rdD)
                            .addComponent(jLabel19))))
                .addContainerGap(30, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(pnTabQuestion, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(pnInfomation, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(pnTabQuestion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnInfomation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Question", new javax.swing.ImageIcon(getClass().getResource("/images/QuestionMark.png")), jPanel1); // NOI18N

        jPanel6.setPreferredSize(new java.awt.Dimension(896, 50));

        btnSearch1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/search.png"))); // NOI18N
        btnSearch1.setText("Search");
        btnSearch1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSearch1ActionPerformed(evt);
            }
        });

        jLabel25.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel25.setForeground(new java.awt.Color(255, 102, 0));
        jLabel25.setText("Question content");

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGap(177, 177, 177)
                .addComponent(jLabel25)
                .addGap(18, 18, 18)
                .addComponent(txtSearh, javax.swing.GroupLayout.PREFERRED_SIZE, 293, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(26, 26, 26)
                .addComponent(btnSearch1)
                .addContainerGap(179, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()
                .addContainerGap(12, Short.MAX_VALUE)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtSearh, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel25)
                    .addComponent(btnSearch1))
                .addContainerGap())
        );

        jPanel7.setPreferredSize(new java.awt.Dimension(452, 380));
        jPanel7.setLayout(new java.awt.BorderLayout());

        tableSearch.setFont(new java.awt.Font("Tahoma", 0, 13)); // NOI18N
        tableSearch.setModel(dtmSearch);
        tableSearch.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tableSearchMouseClicked(evt);
            }
        });
        jScrollPane5.setViewportView(tableSearch);

        jPanel7.add(jScrollPane5, java.awt.BorderLayout.CENTER);

        javax.swing.GroupLayout pnSearchQuestionLayout = new javax.swing.GroupLayout(pnSearchQuestion);
        pnSearchQuestion.setLayout(pnSearchQuestionLayout);
        pnSearchQuestionLayout.setHorizontalGroup(
            pnSearchQuestionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, 896, Short.MAX_VALUE)
        );
        pnSearchQuestionLayout.setVerticalGroup(
            pnSearchQuestionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnSearchQuestionLayout.createSequentialGroup()
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, 465, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Search", new javax.swing.ImageIcon(getClass().getResource("/images/search.png")), pnSearchQuestion); // NOI18N

        pnQuestion.add(jTabbedPane1, java.awt.BorderLayout.CENTER);
        jTabbedPane1.getAccessibleContext().setAccessibleName("Information question table");

        tpManager.addTab("Question", new javax.swing.ImageIcon(getClass().getResource("/images/question.png")), pnQuestion); // NOI18N

        pnUser.setBackground(new java.awt.Color(255, 255, 255));
        pnUser.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", 2, 1, new java.awt.Font("Tahoma", 1, 18))); // NOI18N
        pnUser.setLayout(new java.awt.BorderLayout());

        tablePlayer.setFont(new java.awt.Font("Tahoma", 0, 13)); // NOI18N
        tablePlayer.setModel(dtmPlayer);
        tablePlayer.setEnabled(false);
        jScrollPane2.setViewportView(tablePlayer);

        pnUser.add(jScrollPane2, java.awt.BorderLayout.CENTER);

        tpManager.addTab("Player", new javax.swing.ImageIcon(getClass().getResource("/images/USERS FOLDER.png")), pnUser); // NOI18N

        javax.swing.GroupLayout pnTitleLayout = new javax.swing.GroupLayout(pnTitle);
        pnTitle.setLayout(pnTitleLayout);
        pnTitleLayout.setHorizontalGroup(
            pnTitleLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnTitleLayout.createSequentialGroup()
                .addComponent(tpManager, javax.swing.GroupLayout.PREFERRED_SIZE, 1024, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnTitleLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 790, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(82, 82, 82))
        );
        pnTitleLayout.setVerticalGroup(
            pnTitleLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnTitleLayout.createSequentialGroup()
                .addGap(16, 16, 16)
                .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 69, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tpManager, javax.swing.GroupLayout.PREFERRED_SIZE, 576, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jMenu1.setText("Accout");

        mnPass.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/password.png"))); // NOI18N
        mnPass.setText("Change Pass");
        mnPass.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnPassActionPerformed(evt);
            }
        });
        jMenu1.add(mnPass);

        mnLog.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/log_out.png"))); // NOI18N
        mnLog.setText("Log Out");
        mnLog.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnLogActionPerformed(evt);
            }
        });
        jMenu1.add(mnLog);

        mnExit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/exit.png"))); // NOI18N
        mnExit.setText("Exit");
        mnExit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnExitActionPerformed(evt);
            }
        });
        jMenu1.add(mnExit);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("About");
        jMenu2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenu2ActionPerformed(evt);
            }
        });

        jMenuItem1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/about.png"))); // NOI18N
        jMenuItem1.setText("About");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem1);

        jMenuBar1.add(jMenu2);

        jMenu3.setText("Help");

        jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F1, 0));
        jMenuItem2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/help_copy.png"))); // NOI18N
        jMenuItem2.setText("Help");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem2);

        jMenuBar1.add(jMenu3);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(pnTitle, javax.swing.GroupLayout.DEFAULT_SIZE, 1034, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(pnTitle, javax.swing.GroupLayout.DEFAULT_SIZE, 678, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void mnPassActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnPassActionPerformed
    changePass();
}//GEN-LAST:event_mnPassActionPerformed

private void mnLogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnLogActionPerformed
    new AdminLogin().setVisible(true);
    this.dispose();
}//GEN-LAST:event_mnLogActionPerformed

private void mnExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnExitActionPerformed
    System.exit(0);
}//GEN-LAST:event_mnExitActionPerformed

private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
    About a = new About(null, true);
    a.setVisible(true);
}//GEN-LAST:event_jMenuItem1ActionPerformed

private void jMenu2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenu2ActionPerformed
    About a = new About(null, true);
    a.setVisible(true);
}//GEN-LAST:event_jMenu2ActionPerformed

private void tpManagerAncestorAdded(javax.swing.event.AncestorEvent evt) {//GEN-FIRST:event_tpManagerAncestorAdded
}//GEN-LAST:event_tpManagerAncestorAdded

private void tableQuestionMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tableQuestionMouseClicked

    try {
        // TODO add your handling code here:
        int choose = tableQuestion.getSelectedRow();
        int chooseRow = choose + 1;
        MyConnection.getConn();
        String sqlClick = "select * from Question";
        ResultSet dataClick = MyConnection.resultStatement(sqlClick);
        dataClick.absolute(chooseRow);
        int id = dataClick.getInt("Id");

        String sqlChooseRow = "select * from Question where Id=" + id + "";
        dataOneRow = MyConnection.resultStatement(sqlChooseRow);
        while (dataOneRow.next()) {
            txtContent.setText(dataOneRow.getString("Content"));
            A = dataOneRow.getString("AnswerA");
            B = dataOneRow.getString("AnswerB");
            C = dataOneRow.getString("AnswerC");
            D = dataOneRow.getString("AnswerD");
            txtA.setText(A);
            txtB.setText(B);
            txtC.setText(C);
            txtD.setText(D);
            String correct = dataOneRow.getString("CorrectAnswer");
            if (correct.equals(A)) {
                rdA.setSelected(true);
            } else if (correct.equals(B)) {
                rdB.setSelected(true);
            } else if (correct.equals(C)) {
                rdC.setSelected(true);
            } else if (correct.equals(D)) {
                rdD.setSelected(true);
            }
        }

    } catch (SQLException ex) {
        Logger.getLogger(ManagerAdmin.class.getName()).log(Level.SEVERE, null, ex);
    }

}//GEN-LAST:event_tableQuestionMouseClicked

private void btnSearch1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSearch1ActionPerformed
    try {
        // TODO add your handling code here:
        dtmSearch = new DefaultTableModel(0, 0);
        String searchContent = txtSearh.getText();
        String sqlSearch = "select * from Question where Content like '%" + searchContent + "%'";
        MyConnection.getConn();
        ResultSet dataSearch = MyConnection.resultStatement(sqlSearch);

        tableSearch.setModel(dtmSearch);

        metaSearch = dataSearch.getMetaData();
        int totalColumn = metaSearch.getColumnCount();
        for (int i = 1; i <= totalColumn; i++) {
            dtmSearch.addColumn(metaSearch.getColumnLabel(i));
        }

        while (dataSearch.next()) {

            Vector rowSearch = new Vector();
            rowSearch.add(dataSearch.getInt(1));
            rowSearch.add(dataSearch.getString(2));
            rowSearch.add(dataSearch.getString(3));
            rowSearch.add(dataSearch.getString(4));
            rowSearch.add(dataSearch.getString(5));
            rowSearch.add(dataSearch.getString(6));
            rowSearch.add(dataSearch.getString(7));
            dtmSearch.addRow(rowSearch);
        }
    } catch (SQLException ex) {
        Logger.getLogger(ManagerAdmin.class.getName()).log(Level.SEVERE, null, ex);
    }
}//GEN-LAST:event_btnSearch1ActionPerformed

private void tableSearchMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tableSearchMouseClicked
    btnAdd.setVisible(false);
    btnUpdate.setVisible(true);
    try {
        // TODO add your handling code here:
        int id = chooseRow(tableSearch);
        MyConnection.getConn();
        String sqlChooseRow = "select * from Question where Id=" + id + "";
        dataOneRowSearch = MyConnection.resultStatement(sqlChooseRow);
        while (dataOneRowSearch.next()) {
            txtContent.setText(dataOneRowSearch.getString("Content"));
            String A = dataOneRowSearch.getString("AnswerA");
            String B = dataOneRowSearch.getString("AnswerB");
            String C = dataOneRowSearch.getString("AnswerC");
            String D = dataOneRowSearch.getString("AnswerD");
            txtA.setText(A);
            txtB.setText(B);
            txtC.setText(C);
            txtD.setText(D);
            String correct = dataOneRowSearch.getString("CorrectAnswer");
            if (correct.equals(A)) {
                rdA.setSelected(true);
            } else if (correct.equals(B)) {
                rdB.setSelected(true);
            } else if (correct.equals(C)) {
                rdC.setSelected(true);
            } else if (correct.equals(D)) {
                rdD.setSelected(true);
            }
        }
        btnUpdate.setVisible(false);
    } catch (SQLException ex) {
        Logger.getLogger(ManagerAdmin.class.getName()).log(Level.SEVERE, null, ex);
    }
}//GEN-LAST:event_tableSearchMouseClicked

    private void btnResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnResetActionPerformed
        reset();
    }//GEN-LAST:event_btnResetActionPerformed
    private void btnDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteActionPerformed

        String content = txtContent.getText();
        String A = txtA.getText();
        String B = txtB.getText();
        String C = txtC.getText();
        String D = txtD.getText();
        if (content.equals("") && A.equals("") && B.equals("") && C.equals("") && D.equals("") && (!rdA.isSelected() || !rdB.isSelected() || !rdC.isSelected() || !rdD.isSelected())) {
            JOptionPane.showMessageDialog(this, "You must a record to delete");
        } else {
            try {

                int chooseDelete = JOptionPane.showConfirmDialog(this, "Do you delete ?");;
                if (chooseDelete == JOptionPane.OK_OPTION) {
                    int id = chooseRow(tableQuestion);
                    String sqlRow = "DELETE FROM Question WHERE Id=" + id + "";
                    connect = MyConnection.getConn();
                    MyConnection.update(sqlRow);

                    JOptionPane.showMessageDialog(this, "Delete successfully");
                    //load data again
                    loadQuestionAgain();
                    reset();
                } else {
                    return;


                }

            } catch (Exception ex) {
                Logger.getLogger(ManagerAdmin.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }//GEN-LAST:event_btnDeleteActionPerformed

    private void btnUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnUpdateActionPerformed

        String content = txtContent.getText();
        String A = txtA.getText();
        String B = txtB.getText();
        String C = txtC.getText();
        String D = txtD.getText();
        if (content.equals("") && A.equals("") && B.equals("") && C.equals("") && D.equals("")) {
            JOptionPane.showMessageDialog(this, "You must a record to update");
        } else {
            try {
                int id = chooseRow(tableQuestion);
                String sqlUpdate = "UPDATE Question SET Content=?, AnswerA=?, AnswerB=?, AnswerC=?, AnswerD=?,CorrectAnswer=? WHERE Id=?";
                connect = MyConnection.getConn();
                PreparedStatement ps = connect.prepareCall(sqlUpdate);
                ps.setString(1, content);
                ps.setString(2, A);
                ps.setString(3, B);
                ps.setString(4, C);
                ps.setString(5, D);
                if (rdA.isSelected()) {
                    ps.setString(6, A);
                } else if (rdB.isSelected()) {
                    ps.setString(6, B);
                } else if (rdC.isSelected()) {
                    ps.setString(6, C);
                } else if (rdD.isSelected()) {
                    ps.setString(6, D);
                }
                ps.setInt(7, id);

                ps.executeUpdate();

                JOptionPane.showMessageDialog(this, "Update successfully");

                loadQuestionAgain();
                reset();

            } catch (Exception ex) {
                Logger.getLogger(ManagerAdmin.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }//GEN-LAST:event_btnUpdateActionPerformed

    private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddActionPerformed
        String content = txtContent.getText();
        String A = txtA.getText();
        String B = txtB.getText();
        String C = txtC.getText();
        String D = txtD.getText();

        if (content.equals("")) {
            JOptionPane.showMessageDialog(this, "Please enter content");
            txtContent.requestFocus();
        } else if (A.equals("")) {
            JOptionPane.showMessageDialog(this, "Please enter answer A");
            txtA.requestFocus();
        } else if (B.equals("")) {
            JOptionPane.showMessageDialog(this, "Please enter answer B");
            txtB.requestFocus();
        } else if (C.equals("")) {
            JOptionPane.showMessageDialog(this, "Please enter answer C");
            txtC.requestFocus();
        } else if (D.equals("")) {
            JOptionPane.showMessageDialog(this, "Please enter answer D");
            txtD.requestFocus();
        } else if (!rdA.isSelected() && !rdB.isSelected() && !rdC.isSelected() && !rdD.isSelected()) {
            JOptionPane.showMessageDialog(this, "Please choose correct answer");
        } else if (A.equals("") == false && B.equals("") == false && C.equals("") == false && D.equals("") == false) {
            String[] compareA = new String[]{B, C, D};
            String[] compareB = new String[]{A, C, D};
            String[] compareC = new String[]{A, B, D};
            String[] compareD = new String[]{A, B, C};

            for (int i = 0; i < compareA.length; i++) {
                if (compareA[i].equals(A)) {
                    JOptionPane.showMessageDialog(this, "Answer must be diffirently");
                    return;
                }
            }
            for (int i = 0; i < compareB.length; i++) {
                if (compareB[i].equals(B)) {
                    JOptionPane.showMessageDialog(this, "Answer must be diffirently");
                    return;
                }
            }
            for (int i = 0; i < compareC.length; i++) {
                if (compareC[i].equals(C)) {
                    JOptionPane.showMessageDialog(this, "Answer must be diffirently");
                    return;
                }
            }
            for (int i = 0; i < compareD.length; i++) {
                if (compareD[i].equals(D)) {
                    JOptionPane.showMessageDialog(this, "Answer must be diffirently");
                    return;
                }
            }
        }

        if (!content.equals("") && !A.equals("") && !B.equals("") && !C.equals("") && !D.equals("") && (rdA.isSelected() || rdB.isSelected() || rdC.isSelected() || rdD.isSelected())) {
            ResultSet dataAdd = loadData("Question");
            try {
                while (dataAdd.next()) {
                    String getContent = dataAdd.getString("Content");
                    String getA = dataAdd.getString("AnswerA");
                    String getB = dataAdd.getString("AnswerB");
                    String getC = dataAdd.getString("AnswerC");
                    String getD = dataAdd.getString("AnswerD");
                    String getCorrect = dataAdd.getString("CorrectAnswer");
                    if (content.equals(getContent) && A.equals(getA) && B.equals(getB) && C.equals(getC) && C.equals(getC) && D.equals(getD)) {
                        JOptionPane.showMessageDialog(this, "Question existed");
                        return;
                    }
                }

                dataAdd.moveToInsertRow();
                dataAdd.updateString(2, txtContent.getText());
                dataAdd.updateString(3, txtA.getText());
                dataAdd.updateString(4, txtB.getText());
                dataAdd.updateString(5, txtC.getText());
                dataAdd.updateString(6, txtD.getText());
                if (rdA.isSelected()) {
                    dataAdd.updateString(7, txtA.getText());
                } else if (rdB.isSelected()) {
                    dataAdd.updateString(7, txtB.getText());
                } else if (rdC.isSelected()) {
                    dataAdd.updateString(7, txtC.getText());
                } else if (rdD.isSelected()) {
                    dataAdd.updateString(7, txtD.getText());
                }
                dataAdd.insertRow();
                JOptionPane.showMessageDialog(this, "Add successfully");

                loadQuestionAgain();
                reset();

            } catch (SQLException ex) {
                Logger.getLogger(ManagerAdmin.class.getName()).log(Level.SEVERE, null, ex);
            }
        }


    }//GEN-LAST:event_btnAddActionPerformed
    private void txtDActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtDActionPerformed
    }//GEN-LAST:event_txtDActionPerformed

    private void txtCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtCActionPerformed
    }//GEN-LAST:event_txtCActionPerformed

    private void txtBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtBActionPerformed
    }//GEN-LAST:event_txtBActionPerformed

    private void txtAActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtAActionPerformed
    }//GEN-LAST:event_txtAActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        try {
            String path = new File("").getAbsolutePath() + "\\Help.chm";
            File file = new File(path);

            if (file.exists()) {
                Runtime.getRuntime().exec("rundll32 url.dll, FileProtocolHandler " + path);
            } else {
                throw new Exception("File \"Help.chm\" not found!");
            }
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, "Error: " + ex.getMessage(), "Notice", JOptionPane.OK_OPTION);
        }

    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void lbManageMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lbManageMouseClicked
        changePass();
    }//GEN-LAST:event_lbManageMouseClicked

    private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed

    }//GEN-LAST:event_formWindowClosed
    private void changePass() {
        if (check == false) {
            tpManager.add(new ChangePass());
            check = true;
            tpManager.setIconAt(3, icon);
            tpManager.setTitleAt(3, "PassWord");
            tpManager.setSelectedIndex(3);
        }
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAdd;
    private javax.swing.JButton btnDelete;
    private javax.swing.JButton btnReset;
    private javax.swing.JButton btnSearch1;
    private javax.swing.JButton btnUpdate;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.JLabel countQuestion;
    private javax.swing.JLabel countUser;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JLabel lbAddress;
    private javax.swing.JLabel lbDate;
    private javax.swing.JLabel lbEmail;
    private javax.swing.JLabel lbManage;
    private javax.swing.JLabel lbName;
    private javax.swing.JLabel maxMoney;
    private javax.swing.JLabel maxMoney1;
    private javax.swing.JMenuItem mnExit;
    private javax.swing.JMenuItem mnLog;
    private javax.swing.JMenuItem mnPass;
    private javax.swing.JPanel pnInfomation;
    private javax.swing.JPanel pnQuestion;
    private javax.swing.JPanel pnSearchQuestion;
    private javax.swing.JPanel pnStatistics;
    private javax.swing.JPanel pnTabQuestion;
    private javax.swing.JPanel pnTitle;
    private javax.swing.JPanel pnUser;
    private javax.swing.JRadioButton rdA;
    private javax.swing.JRadioButton rdB;
    private javax.swing.JRadioButton rdC;
    private javax.swing.JRadioButton rdD;
    private javax.swing.JTable tablePlayer;
    private javax.swing.JTable tableQuestion;
    private javax.swing.JTable tableSearch;
    private javax.swing.JTabbedPane tpManager;
    private javax.swing.JTextField txtA;
    private javax.swing.JTextField txtB;
    private javax.swing.JTextField txtC;
    private javax.swing.JTextArea txtContent;
    private javax.swing.JTextField txtD;
    private javax.swing.JTextField txtSearh;
    // End of variables declaration//GEN-END:variables
}
